﻿using System;
using System.Web.UI;
using QzEbook.Admin;
using QzEbook.AccessObject;
using QzEbook.BaseView;

namespace qzEbook.module
{
    public partial class editUserInfo : System.Web.UI.UserControl
    {
        SiteUser siteuser;
        protected void Page_Load(object sender, EventArgs e)
        {
            SessionUser userSession = Session["User"] as SessionUser;
            siteuser = new SiteUser();
            siteuser.Uid = userSession.Uid;

            if (!IsPostBack)
            {
                bindPage();
            }
        }

        private void bindPage()
        {
            
            siteuser=siteuser.select();
            SexRbl.SelectedValue = (siteuser.Sex == true ? "1" : "0");
            fromTb.Text = siteuser.From;
            qqTb.Text = siteuser.Qq;
        }


        protected void UpDateUserBtn_Click(object sender, EventArgs e)
        {
            siteuser.Sex = SexRbl.SelectedValue=="1";
            siteuser.Qq = qqTb.Text.Trim();
            siteuser.From = fromTb.Text.Trim();
            bool action=siteuser.update();
            if (action)
            {
                UserPage userpage = this.Page as UserPage;
                bindPage();
                userpage.alert("更新成功");
            }
        }
    }
}
